package com.boyicloud.exchangeserver

import com.boyicloud.exchangeserver.common.NettyServerProperties
import com.boyicloud.exchangeserver.netty.listener.NettyServerListener
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class ExchangeServerApplication : CommandLineRunner {

    @Autowired
    lateinit var nettyServerListener: NettyServerListener

    @Autowired
    lateinit var nettyServerProperties: NettyServerProperties

    override fun run(vararg args: String?) {
        nettyServerListener.start(nettyServerProperties.softwarePort!!, NettyServerListener.ServerType.SOFTWARE)
        nettyServerListener.start(nettyServerProperties.equipmentPort!!, NettyServerListener.ServerType.EQUIPMENT)
    }
}

fun main(args: Array<String>) {
    runApplication<ExchangeServerApplication>(*args)
}
